{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb2}
		</small>	
	</h1>
</div>	

<table class="table table-striped table-bordered table-hover search-form">
	<thead>
		<th><input name="order" type="text" placeholder="输入订单号" value="{:input('param.order')}" /></th>
		
		<th>
			<select name="score">
				<option value="">全部评分</option>			
				<?php $input_score=input('param.score'); ?>				
				<option {if condition="$input_score eq 1"} selected="selected"{/if} value="1">一星差评</option>
				<option {if condition="$input_score eq 2"} selected="selected"{/if} value="2">二星</option>
				<option {if condition="$input_score eq 3"} selected="selected"{/if} value="3">三星</option>
				<option {if condition="$input_score eq 4"} selected="selected"{/if} value="4">四星</option>
				<option {if condition="$input_score eq 5"} selected="selected"{/if} value="5">五星</option>
			</select>
		</th>
		<th><?php $input_status=input('param.status'); ?>	
			<select name="status">
				<option value="">全部状态</option>								
				<option {if condition="$input_status eq 1"} selected="selected"{/if} value="1">已通过</option>
				<option {if condition="isset($input_status) and $input_status eq 0"} selected="selected"{/if} value="0">未通过</option>
				
			</select>
		</th>
		<th>
			<a class="btn btn-primary" href="javascript:;" id="search" url="{:url('CommentBackend/index')}">查询</a>
		</th>
	</thead>
</table>	

<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>	
						<th>商品信息</th> 
						<th>订单</th>
						<th>评分</th> 
						<th>评价</th> 									
						<th>时间</th>	
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
						
						{volist name="list" id="v" empty="$empty"}
						<tr>	
							<td>
								<a title="{$v.name}" href='{:url("/goods/".$v["goods_id"])}'>
									<img src="IMG_ROOT{$v.image|resize=60,60}">
								</a>	
							</td>
							<td>							
								<a href='{:url("OrderBackend/show_order",array("id"=>$v["order_id"]))}'>
								{$v.order_num_alias}
								</a>							
							</td>
							<td>
								<div class="raty" data='{$v.score}'></div>
							</td>
							<td>{$v.content}</td>
							
							<td>
								{$v.create_time|date="Y-m-d",###}
							</td>
							<td>
								{switch name="v.status"}
									{case value="1"}
									<span class="green">已通过</span>
									{/case}
									{case value="0"}
									<span class="red">未通过</span>
									{/case}
								{/switch}
							</td>
							<td>							
							{switch name="v.status"}
								{case value="0"}<a class="pass" title="启用" href='{:url("CommentBackend/set_status",array("id"=>$v["id"],"status"=>1,"goods_id"=>$v["goods_id"]))}'><span class="btn btn-xs btn-success"><i class="fa fa-check bigger-120"></i></span></a>{/case}
								{case value="1"}<a class="jin" title="禁用" href='{:url("CommentBackend/set_status",array("id"=>$v["id"],"status"=>0,"goods_id"=>$v["goods_id"]))}'><span class="btn btn-xs btn-danger"><i class="fa fa-remove bigger-120"></i></span></a>{/case}
							{/switch}
								
							</td>
						</tr>
						{/volist}	
						
						<tr>
							<td colspan="20" class="page">{$list->render()}</td>
						</tr>
					
				</tbody>
				
			</table>
		</div>
	</div>
</div>
{/block}
{block name="javascript"}
<script src="__PUBLIC__/js/jquery/raty/jquery.raty.min.js"></script>
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
    
});

	$('.raty').each(function(i){
			var score=$(this).attr('data');
			$(this).raty({
		   		starHalf: '__PUBLIC__/js/jquery/raty/img/star-half.png',
		   		starOff: '__PUBLIC__/js/jquery/raty/img/star-off.png',
		  		starOn : '__PUBLIC__/js/jquery/raty/img/star-on.png',
		   		readOnly: true, 
		   		score: score 
	   		});
			
	});
	
	$('.pass').click(function(){
		var f=confirm('确认要启用该评论吗？');
		if(f==false){
			return false;
		}
	});		
	
	$('.jin').click(function(){
		var f=confirm('确认要禁用该评论吗？');
		if(f==false){
			return false;
		}
	});	
</script>
{/block}